package com.woniuxy.rbac.service.impl;

import com.woniuxy.rbac.entity.Perm;
import com.woniuxy.rbac.mapper.PermMapper;
import com.woniuxy.rbac.service.PermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 权限
 *
 * @Auther: 老谭（<a href="http://www.woniuxy.com">蜗牛学苑</a>）
 */
@Service
public class PermServiceImpl implements PermService {
    @Autowired
    private PermMapper permMapper;


    @Override
    public List<Perm> getPermsByUserId(int userId) {
        return permMapper.getPermByUserId(userId);
    }

    @Override
    public List<Perm> getMenusByUserId(int userId) {
        return permMapper.getMenuByUserId(userId);
    }

    /**
     * 根据连接查询所需的权限
     *
     * @param link
     * @return
     */
    @Override
    public Perm getByLink(String link) {
        return permMapper.getByLink(link);
    }

    @Override
    public List<Perm> getPerms() {
        return permMapper.getAllPerms();
    }

    @Override
    public List<Perm> getMenus() {
        return permMapper.getAllMenus();
    }

    @Override
    public List<Perm> getAll() {
        return permMapper.getAll();
    }

    @Override
    public List<Perm> getPermsByROleId(int roleId) {
        return permMapper.getByRoleId(roleId);
    }
}
